package cli

import (
	"github.com/micro/go-micro/cmd"
	contact "git.oschina.net/fanbuchi/xgggh/users/proto/user/contact"
	"github.com/micro/go-micro/client"
	//"github.com/micro/go-micro/metadata"
	"golang.org/x/net/context"
	"errors"
	"fmt"
)

func MyContact(ctx context.Context,search *contact.SearchReq)(*contact.SearchRsp,error) {
	cmd.Init()

	// Use the generated client stub
	_client:=client.DefaultClient
	cl := contact.NewContactsClient("com.xgggh.srv.users", _client)

	// Set arbitrary headers in context
	//ctx := metadata.NewContext(context.Background(), map[string]string{
	//	"X-User-Id": "john",
	//	"X-From-Id": "script",
	//})
	//ctx:=context.Background()
	// Make request
	rsp, err := cl.Search(ctx, search)
	if err != nil {
		return nil,err
	}
	if rsp ==nil{
		return nil,errors.New("token error")
	}
	return rsp,nil
}
